<template>
  <div class="login-phone">
    <el-form :rules="rules" :model="phoneInfo" ref="phoneRef">
      <el-form-item label="手机号" prop="phone">
        <el-input v-model="phoneInfo.phone"></el-input>
      </el-form-item>
      <el-form-item label="验证码" prop="code">
        <div class="code">
          <el-input v-model="phoneInfo.code"></el-input>
          <el-button type="primary" class="code-btn">发送验证码</el-button>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref } from 'vue';
import { rules } from '../config/phone-config';
import type { FormInstance } from 'element-plus';
const phoneInfo = reactive({
  phone: '',
  code: ''
});
// const phoneRules = reactive<FormRules>();
const phoneRef = ref<FormInstance>();
const phoneLogin = () => {
  phoneRef.value?.validate((vali) => {
    if (vali) {
      console.log('手机登陆通过验证');
    } else {
      return false;
    }
  });
};
defineExpose({ phoneLogin });
</script>

<style scoped lang="less">
.code {
  display: flex;
  .code-btn {
    margin-left: 10px;
  }
}
</style>
